package atguigu07.object.equals.exer1;

/**
 * ClassName: Order
 * Package: atguigu07.object.equals.exer1
 * Description:
 *
 * @Author BuTang
 * @Create 2023/3/8 20:44
 * @Version 1.0
 */
public class Order {
    public static void main(String[] args) {
        Order o1 = new Order(123 ,"12");
        Order o2 = new Order(123 ,"123");
        System.out.println(o1.equals(o2));
    }
    private int orderId;
    private String orderName;

    public Order(int orderId, String orderName) {
        this.orderId = orderId;
        this.orderName = orderName;
    }

    public int getOrderId() {
        return orderId;
    }

    public void setOrderId(int orderId) {
        this.orderId = orderId;
    }

    public String getOrderName() {
        return orderName;
    }

    public void setOrderName(String orderName) {
        this.orderName = orderName;
    }

    @Override
    public boolean equals(Object obj) {
        if (this ==obj ) {
            return true;
        }
        else if (obj instanceof Order) {
            Order o = (Order) obj;
            return this.orderId == o.orderId&&this.orderName==o.getOrderName();
        }
        return false;
    }
}
